import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem } from '@/utils/sessionStorage'

Vue.use(Vuex)

const TOKENKEY = 'TOKENKEY'
export default new Vuex.Store(
  {
    state: {
      user: getItem(TOKENKEY)
    },
    mutations: {
      setUser (state, payhod) {
      // 存储到本地
        setItem(TOKENKEY, payhod)
        //  存储到Vuex
        state.user = payhod
      }
    }
  }
)
